<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title></title>
<meta name="Generator" content="Cocoa HTML Writer">
<meta name="CocoaVersion" content="824.44">
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #ad140d}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Helvetica; min-height: 22.0px}
p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Helvetica}
p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}
p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px}
p.p6 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; min-height: 12.0px}
p.p7 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco}
span.s1 {color: #001bb9}
span.s2 {color: #000000}
span.s3 {color: #2c7014}
span.Apple-tab-span {white-space:pre}
</style>
</head>
<body>
<p class="p1">//SLUGens released under the GNU GPL as extensions for SuperCollider 3, by Nick Collins, http://www.informatics.sussex.ac.uk/users/nc81/</p>
<p class="p2"><br></p>
<p class="p3"><b>Instruction<span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>instruction synthesis (breakpoint set interpreter)</b></p>
<p class="p2"><br></p>
<p class="p4"><b>Instruction.ar(bufnum, mul, add)</b></p>
<p class="p5"><br></p>
<p class="p4">Converts a buffer of virtual machine instructions into synthesis. Based on breakpoint manipulation with linear interpolation.<span class="Apple-converted-space"> </span></p>
<p class="p5"><br></p>
<p class="p4"><b>bufnum</b>- Number of buffer holding instructions on the server in the form of successive COMMAND/PARAM PAIRS</p>
<p class="p5"><br></p>
<p class="p4">The limited command set:<span class="Apple-converted-space"> </span></p>
<p class="p5"><br></p>
<p class="p4">0 interpolate from last to new breakpoint over PARAM *5000 samples (ie down to about 10 Hz, sampling rate dependent)<span class="Apple-converted-space"> </span></p>
<p class="p4">1 new random breakpoint from PARAM.rand2</p>
<p class="p4">2 new breakpoint by perturbing last breakpoint amp by PARAM</p>
<p class="p4">3 new breakpoint by interpolating from last breakpoint amp to its inversion</p>
<p class="p4">4 new beakpoint by interpolating (t=PARAM) last two breakpoints (zero amp breakpoint by instruction (3,1) then (4,0.5))</p>
<p class="p4">5 new breakpoint by damping last breakpoint amp (multiply by damping), damping= PARAM</p>
<p class="p4">6 new breakpoint at amplitude +PARAM</p>
<p class="p5"><br></p>
<p class="p4">8 do next command if probability PARAM</p>
<p class="p4">9 goto instruction PARAM within the buffer</p>
<p class="p5"><br></p>
<p class="p4">In most cases, sensible values for PARAM are from 0.0 to 1.0!<span class="Apple-converted-space">  </span>But instruction 9 will need much larger address values.<span class="Apple-converted-space"> </span></p>
<p class="p6"><br></p>
<p class="p6"><br></p>
<p class="p1">//Examples</p>
<p class="p6"><br></p>
<p class="p1">//random instruction sets</p>
<p class="p7">(</p>
<p class="p7">a=<span class="s1">Array</span>.fill(50,{<span class="s1">arg</span> i; if(i.even,{7.rand},{1.0.rand})});</p>
<p class="p7">b=<span class="s1">Buffer</span>.sendCollection(s, a, 1);</p>
<p class="p7">)</p>
<p class="p1">//could be very loud! CAREFUL</p>
<p class="p7">{<span class="s1">Out</span>.ar(0,<span class="s1">Pan2</span>.ar(0.5*<span class="s1">Instruction</span>.ar(b.bufnum),0.0))}.play</p>
<p class="p6"><br></p>
<p class="p7">(</p>
<p class="p7">a=<span class="s1">Array</span>.fill(50,{<span class="s1">arg</span> i; if(i.even,{7.rand},{1.0.rand})});</p>
<p class="p1"><span class="s2">Post &lt;&lt; a &lt;&lt; nl;<span class="Apple-converted-space">  </span></span>//in case you like one</p>
<p class="p7">b.sendCollection(a);</p>
<p class="p7">)</p>
<p class="p6"><br></p>
<p class="p6"><br></p>
<p class="p7">(</p>
<p class="p7">t=<span class="s1">Task</span>({</p>
<p class="p6"><br></p>
<p class="p7"><span class="s1">inf</span>.do {</p>
<p class="p6"><br></p>
<p class="p7">a=<span class="s1">Array</span>.fill(50,{<span class="s1">arg</span> i; if(i.even,{7.rand},{1.0.rand})});</p>
<p class="p7">b.sendCollection(a);</p>
<p class="p6"><br></p>
<p class="p7">exprand(0.05,1).wait;</p>
<p class="p7">}</p>
<p class="p6"><br></p>
<p class="p7">}</p>
<p class="p7">).play;</p>
<p class="p7">)</p>
<p class="p6"><br></p>
<p class="p7">t.stop;</p>
<p class="p6"><br></p>
<p class="p6"><br></p>
<p class="p1">//more considerate construction of instruction sets</p>
<p class="p6"><br></p>
<p class="p7">(</p>
<p class="p7">a= <span class="s1">Array</span>.fill(40,{<span class="s1">arg</span> i; if(i.odd,{if(0.6.coin,{[0,exprand(0.005,0.05)]}, {[8,rrand(0.1,1.0),9,2*rrand(0,12)]})},{[rrand(1,6),[exprand(0.1,1.0),rrand(0.1,1.0),exprand(0.01,0.2)].choose]}); }).flatten;</p>
<p class="p7">Post &lt;&lt; a &lt;&lt; nl;</p>
<p class="p7">b=<span class="s1">Buffer</span>.sendCollection(s, a, 1);</p>
<p class="p7">)</p>
<p class="p6"><br></p>
<p class="p1">//could be very loud! CAREFUL</p>
<p class="p7">{<span class="s1">Out</span>.ar(0,<span class="s1">Pan2</span>.ar(0.5*<span class="s1">Instruction</span>.ar(b.bufnum),0.0))}.play</p>
<p class="p6"><br></p>
<p class="p7">(</p>
<p class="p7">a= <span class="s1">Array</span>.fill(30,{<span class="s1">arg</span> i; if(i.odd,{if(0.6.coin,{[0,exprand(0.005,0.05)]}, {[8,rrand(0.1,1.0),9,2*rrand(0,12)]})},{[rrand(1,6),[exprand(0.1,1.0),rrand(0.1,1.0),exprand(0.01,0.2)].choose]}); }).flatten.postln;</p>
<p class="p7">Post &lt;&lt; a &lt;&lt; nl;</p>
<p class="p7">b.sendCollection(a);</p>
<p class="p7">)</p>
<p class="p6"><br></p>
<p class="p6"><br></p>
<p class="p7">{<span class="s1">Out</span>.ar(0,<span class="s1">Pan2</span>.ar(0.5*<span class="s1">FreeVerb</span>.ar(<span class="s1">Resonz</span>.ar(<span class="s1">Instruction</span>.ar(b.bufnum),<span class="s1">MouseX</span>.kr(1000,5000,<span class="s3">'exponential'</span>),<span class="s1">MouseY</span>.kr(0.01,1.0,<span class="s3">'exponential'</span>))),0.0))}.play</p>
<p class="p6"><br></p>
<p class="p6"><br></p>
<p class="p1">//discovered sounds</p>
<p class="p7">(</p>
<p class="p7">a=[ 2, 0.98085289001465, 0, 0.0098705891385231, 3, 0.045249921951092, 8, 0.426873087883, 9, 12, 6, 0.042719216229536, 8, 0.38374520540237, 9, 22, 6, 0.040797999461159, 8, 0.71095678806305, 9, 8, 2, 0.18426358043098, 8, 0.96414197683334, 9, 10, 2, 0.064978396873361, 0, 0.014289879691635, 5, 0.015798983078423, 0, 0.038866613949307, 6, 0.030472403359923, 0, 0.036071279863708, 1, 0.046212260612025, 8, 0.610464823246, 9, 0, 1, 0.96948568820953, 0, 0.014026194255798, 3, 0.12740938462649, 0, 0.010742629527544, 1, 0.3477209756392, 8, 0.82419589757919, 9, 18, 6, 0.97822250127792, 0, 0.0073386436293812, 4, 0.1197158617971, 8, 0.37467901706696, 9, 20, 6, 0.023095168080617, 0, 0.0077425603088712 ];</p>
<p class="p7">b.sendCollection(a);</p>
<p class="p7">)</p>
<p class="p6"><br></p>
<p class="p6"><br></p>
<p class="p7">(</p>
<p class="p7">a=[ 3, 0.40293287038803, 0, 0.0099009671713598, 2, 0.1265909910202, 0, 0.013731463839874, 3, 0.23790548574176, 0, 0.0077773798350805, 3, 0.15899796225456, 8, 0.88809416294098, 9, 14, 2, 0.16874264604912, 0, 0.0054302242992324, 2, 0.065863798551897, 8, 0.31685080528259, 9, 6, 1, 0.025768143119174, 0, 0.022224710655753, 1, 0.021351216507072, 8, 0.45115448236465, 9, 24, 2, 0.91734998226166, 0, 0.0085382244719742, 1, 0.1098612352863, 0, 0.005935074104977, 5, 0.40578903363382, 8, 0.11921266317368, 9, 2, 6, 0.11252887270072, 0, 0.0066305213330409, 4, 0.51733835087186, 8, 0.78307151794434, 9, 14, 3, 0.86774248188551, 8, 0.54493169784546, 9, 4, 4, 0.46118148424678, 8, 0.21504091024399, 9, 4];</p>
<p class="p7">b.sendCollection(a);</p>
<p class="p7">)</p>
<p class="p6"><br></p>
</body>
</html>
